package com.jinke.api.modules.app.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jinke.api.common.api.CommonResult;
import com.jinke.api.modules.app.controller.param.MaterialRechargeParam;
import com.jinke.api.modules.app.enums.BalanceLogType;
import com.jinke.api.modules.app.model.BalanceLog;
import com.jinke.api.modules.app.model.UserRecharge;
import com.jinke.api.modules.app.request.UserRechargeRequest;
import com.jinke.api.modules.app.response.UserRechargeListVO;
import com.jinke.api.modules.third.easypost.model.request.CancelInsuranceDTO;
import com.jinke.api.modules.ums.model.Channel;
import com.jinke.api.modules.ums.request.ApproveRequest;
import com.jinke.api.modules.ums.request.FindZoneRequest;
import com.jinke.api.modules.ums.request.RechargeRequest;
import com.jinke.api.modules.ums.vo.FindZoneVo;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author macro
 * @since 2024-01-13
 */
public interface UserRechargeService extends IService<UserRecharge> {

    Page<UserRechargeListVO> list(UserRechargeRequest request);
    //返回分页对象   根据给定的充值请求对象 request 查询用户充值记录列表

    boolean approve(ApproveRequest request);

    @Transactional
    boolean recharge(RechargeRequest request);

    boolean incr(Integer userId, BigDecimal amount, BalanceLogType type, String remark, String orderNo, List<BalanceLog.Detail> details );

    /**
     * 扣钱不成 当场取消
     *      * 如果不需要当场取消 String objectId, Channel channel可以传null
     * @param userId
     * @param amount 运费
     * @param type
     * @param remark
     * @param orderNo
     * @param objectId
     * @param channel
     * @param insurance 保险如果没有就传null
     * @return
     */
    boolean decrTransfer(Integer userId, BigDecimal amount, BalanceLogType type, String remark, String orderNo, String objectId, Channel channel , CancelInsuranceDTO insurance );



    CommonResult<String> downloadInvoice(Long rechargeId, HttpServletResponse response) throws IOException;

    CommonResult<String> rechargeYear(MaterialRechargeParam materialRechargeParam);

    CommonResult<List<FindZoneVo>> getAllZone(FindZoneRequest findZoneRequest);
}
